<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Person(name, age) {
            this.name = name;
            this.age = age;

        }

        var obj = {
            speak: function() {
                console.log('hello')
            },
            nation: 'China',
            address: '北京市'
        }

        Person.prototype = obj;
        Person.prototype.constructor = Person;

        //为原型添加一个值
        Person.prototype.num = 100;

        //创建对象
        var p = new Person('Tom', 12);
        console.log(p.name);
        console.log(p.nation);
        console.log(p.num);
    </script>

</body>

</html>